package com.trkj.service;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSON;
import com.trkj.dao.DeptDAO;
import com.trkj.dao.EmpDAO;
import com.trkj.dao.EmployDAO;
import com.trkj.dao.LeaveDAO;
import com.trkj.dao.LoanDAO;
import com.trkj.dao.OverworkDAO;
import com.trkj.dao.PositionDAO;
import com.trkj.dao.QuitDAO;
import com.trkj.dao.ReloanDAO;
import com.trkj.dao.StandardDAO;
import com.trkj.dao.TransferDAO;
import com.trkj.pojo.Dept;
import com.trkj.pojo.Emp;
import com.trkj.pojo.Employ;
import com.trkj.pojo.Loan;
import com.trkj.pojo.Overwork;
import com.trkj.pojo.Position;
import com.trkj.pojo.Quit;
import com.trkj.pojo.Reloan;
import com.trkj.pojo.Standard;
import com.trkj.pojo.Transfer;
import com.trkj.utils.DataGrid;
import com.trkj.vo.CreatePositionVo;
import com.trkj.vo.DeptInfoVo;
import com.trkj.vo.DeptPositionVo;
import com.trkj.vo.DeptVo;
import com.trkj.vo.EmpRoleVo;
import com.trkj.vo.EmpVo;
import com.trkj.vo.PositionDeptVo;
import com.trkj.vo.PositionInfoVo;

/**
 * 部门管理service
 * @author 吴山峰
 *
 */
@Service
@Transactional
public class DeptService {
	@Autowired
	DeptDAO deptDAO;
	@Autowired
	EmpDAO empDAO;
	@Autowired
	PositionDAO positionDAO;
	@Autowired
	EmployDAO employDAO;
	@Autowired
	LeaveDAO leaveDAO;
	@Autowired
	LoanDAO loanDAO;
	@Autowired
	OverworkDAO overworkDAO;
	@Autowired
	QuitDAO quitDAO;
	@Autowired
	ReloanDAO reloanDAO;
	@Autowired
	StandardDAO standardDAO;
	@Autowired
	TransferDAO transferDAO;
	/**
	 * 查询所有的部门信息
	 */
	public DataGrid findAllDeptInfo(String deptname, Integer page, Integer rows, String sort, String order) {
		Pageable pageable = new PageRequest(page-1, rows, new Sort(Sort.Direction.fromStringOrNull(order), sort));
		Page<Dept> pageSelect = pageSelect(deptname, pageable);
		List<Dept> list = pageSelect.getContent();
		System.out.println(list.size()+deptname);
		List<DeptInfoVo> deptInfoVos = new ArrayList<>();
		for (Dept dept : list) {
			DeptInfoVo deptInfoVo = new DeptInfoVo();
			deptInfoVo.setDeptId(dept.getDeptId());
			deptInfoVo.setDeptName(dept.getDeptName());
			deptInfoVo.setEmpNumber(dept.getEmps()==null?0:dept.getEmps().size());
			deptInfoVo.setPosNumber(dept.getPositions()==null?0:dept.getPositions().size());
			deptInfoVo.setSuperDept(dept.getDept()==null?null:dept.getDept().getDeptName());
			deptInfoVo.setSuperDeptId(dept.getDept()==null?0:dept.getDept().getDeptId());
			deptInfoVos.add(deptInfoVo);
		}
		return new DataGrid(pageSelect.getTotalElements(), deptInfoVos);
	}
	/**
	 * 创建分页查询
	 */
	public Page<Dept> pageSelect(String deptname, Pageable pageable) {
		Page<Dept> page = deptDAO.findAll(new Specification<Dept>() {
			@Override
			public Predicate toPredicate(Root<Dept> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
				Predicate p1 = null;
				if(deptname!=null && deptname.length()>0) {
					p1 = cb.like(root.get("deptName"), "%"+deptname+"%");
					return cb.or(p1);
				}else {
					return null;
				}
			}
		}, pageable);
		return page;
	}
	/**
	 * 查询职位信息
	 */
	public DataGrid findAllPositionInfo(Integer deptid, String posname, Integer page, Integer rows) {
		Pageable pageable = new PageRequest(page-1, rows);
		Page<Position> pageselect = pageselect(deptid, posname, pageable);
		List<Position> Positions = pageselect.getContent();
		List<PositionInfoVo> positionVos = new ArrayList<>();
		for (Position position : Positions) {
			PositionInfoVo positionInfoVo = new PositionInfoVo();
			positionInfoVo.setPositionId(position.getPositionId());
			positionInfoVo.setPositionDesc(position.getPositionDesc());
			positionInfoVo.setPositionLevel(position.getPositionLevel());
			positionInfoVo.setPositionName(position.getPositionName());
			positionInfoVo.setPositionNumber(position.getPositionNumber());
			positionInfoVo.setPositionOrgan(position.getPositionOrgan());
			positionInfoVo.setSuperPosition(position.getPosition()==null?"":position.getPosition().getPositionName());
			positionInfoVo.setSuperPositionId(position.getPosition()==null?0:position.getPosition().getPositionId());
			positionVos.add(positionInfoVo);
		}
		return new DataGrid(pageselect.getTotalElements(), positionVos);
	}
	/**
	 * 创建查询
	 */
	public Page<Position> pageselect(Integer deptid, String posname, Pageable pageable) {
		Page<Position> page = positionDAO.findAll(new Specification<Position>() {
			@Override
			public Predicate toPredicate(Root<Position> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
				Predicate p1=null;
				Predicate p2=null;
				/*String starttimes = starttime.toLocaleString();
				String endtimes = endtime.toLocaleString();*/
				Join<Dept, Position> join = root.join("dept", JoinType.LEFT);
				List<Predicate> list = new ArrayList<Predicate>();
				if (deptid != null) {
					p1 = cb.equal(join.get("deptId"), deptid);
					list.add(p1);
				}
				if(posname!=null) {
					p2 = cb.like(root.get("positionName"), "%"+posname+"%");
					list.add(p2);
				} 
				Predicate[] p = new Predicate[list.size()];
	            return cb.and(list.toArray(p));
			}
		},pageable);
		return page;
	}
	/**
	 * 根据部门id查询除该部门外的其他部门
	 */
	public List<DeptVo> findOtherDeptById(Integer deptid) {
		List<Dept> depts = deptDAO.queryOtherDept(deptid);
		List<DeptVo> deptVos = new ArrayList<>();
		deptVos.add(new DeptVo(0, "--无--", null));
		for (Dept dept : depts) {
			DeptVo deptVo = new DeptVo();
			deptVo.setDeptId(dept.getDeptId());
			deptVo.setDeptname(dept.getDeptName());
			deptVos.add(deptVo);
		}
		return deptVos;
	}
	/**
	 * 查询所有部门--用于新建部门选择上级部门
	 */
	public List<DeptVo> findAllEasyDept() {
		List<Dept> depts = deptDAO.findAll();
		List<DeptVo> deptVos = new ArrayList<>();
		deptVos.add(new DeptVo(0, "--无--", null));
		for (Dept dept : depts) {
			DeptVo deptVo = new DeptVo();
			deptVo.setDeptId(dept.getDeptId());
			deptVo.setDeptname(dept.getDeptName());
			deptVos.add(deptVo);
		}
		return deptVos;
	}
	/**
	 * 根据部门编号查询某个部门下面的所有员工
	 */
	public List<Emp> findDeptAllEmp(Integer deptid) {
		Dept dept = deptDAO.findOne(deptid);
		List<Emp> emps = dept.getEmps();
		return emps;
	}
	
	/**
	 * 查询未分配部门的员工 ，已经分配部门的员工不可以再次进行分配
	 */
	public List<EmpVo> findNotDeptEmp() {
		List<Emp> emps = empDAO.findAll();
		List<EmpVo> empvos = new ArrayList<>();
		
		for (Emp emp : emps) {
			if(emp.getDept()==null) {
				EmpVo empVo = new EmpVo();
				empVo.setEmpid(emp.getEmpId());
				empVo.setEmpname(emp.getEmpName());
				empVo.setIscheck(false);
				empvos.add(empVo);
			}
		}
		return empvos;
	}
	
	/**
	 * 查询该部门下的职位，用于添加员工
	 */
	public List<DeptPositionVo> findDeptPosition(Integer deptid) {
		Dept dept = deptDAO.findOne(deptid);
		List<DeptPositionVo> DeptPositionVos=null;
		if(dept.getPositions()!=null) {
			List<Position> positions = dept.getPositions();
			//判断职位的编制是否满员了，已经满员的话无需添加
				DeptPositionVos = new ArrayList<>();
				for (Position position : positions) {
					if(position.getPositionNumber()<position.getPositionOrgan()) {
						DeptPositionVo dVo = new DeptPositionVo();
							if(DeptPositionVos.size()==0) {
								dVo.setSel(true);
							}
							dVo.setPositionId(position.getPositionId());
							dVo.setPositionName(position.getPositionName());
						DeptPositionVos.add(dVo);
					}
				}
			}
		return DeptPositionVos;
	}
	/**
	 * 查询部门下职位编制未满的职位数量
	 * @return 
	 */
	public boolean findDeptPositionNumber(Integer deptid) {
		List<DeptPositionVo> posi = findDeptPosition(deptid);
		return posi.size()>0?true:false;
	}
	/**
	 * 分配员工到部门
	 */
	public boolean giveDeptIsEmp(Integer deptid, Integer empid, Integer positionid) {
		try{
		Dept dept = deptDAO.findOne(deptid);
		Emp emp = empDAO.findOne(empid);
		Position position = positionDAO.findOne(positionid);
		emp.setPosition(position);
		emp.setDept(dept);
		position.setPositionNumber(position.getPositionNumber()+1);
		empDAO.save(emp);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}
	/**
	 * 重新分配部门的员工
	 */
	public boolean addEmpToDept(Integer deptid, String empids) {
		try {
			String[] arrEmpids = null;
			Dept dept = deptDAO.findOne(deptid);
			//先清空部门里面的员工
			if(dept.getEmps() != null) {
				dept.getEmps().clear();
			}
			//截取员工id
			if(empids!=null && empids.length()>0) {
				arrEmpids = empids.split(",");
			}
			//重新分配员工到部门里面
			if (arrEmpids!=null) {
				for (int i = 0; i < arrEmpids.length; i++) {
					Emp emp = empDAO.findOne(Integer.parseInt(arrEmpids[i]));
					dept.getEmps().add(emp);
				}
			} 
			return true;
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}
	/**
	 * 根据员工id查询该员工是否有职务，有则返回职务，没有返回空
	 */
	public DeptPositionVo queryPositionByEmpId(Integer empid) {
		Emp emp = empDAO.findOne(empid);
		DeptPositionVo deptPositionVo = new DeptPositionVo();
		if(emp.getPosition()!=null) {
			deptPositionVo.setPositionId(emp.getPosition().getPositionId());
			deptPositionVo.setPositionName(emp.getPosition().getPositionName());
		}
		return deptPositionVo;
	}
	/**
	 * 新增部门/编辑部门
	 */
	public boolean addNewDept(DeptInfoVo deptInfo) {
		try {
			Dept dept = new Dept();
			dept.setDeptId(deptInfo.getDeptId());
			dept.setDeptName(deptInfo.getDeptName());
			if(deptInfo.getSuperDept()!=null && deptInfo.getSuperDept().length()>0) {
				Dept superdept = deptDAO.findOne(Integer.parseInt(deptInfo.getSuperDept()));
				dept.setDept(superdept);
			}
			deptDAO.save(dept);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}
	/**
	 * 删除部门
	 */
	public boolean removeDept(Integer deptid) {
		try {
			//删除部门之前先把关系解除掉
			Dept dept = deptDAO.findOne(deptid);
			if(dept.getDepts()!=null && dept.getDepts().size()>0) {
				List<Dept> depts = dept.getDepts();
				for (Dept dept2 : depts) {
					dept2.setDept(null);
				}
				deptDAO.save(depts);
				dept.getDepts().clear();
			}
			if(dept.getEmploys()!=null && dept.getEmploys().size()>0) {
				List<Employ> employs = dept.getEmploys();
				for (Employ employ : employs) {
					employ.setDept(null);
				}
				employDAO.save(employs);
				dept.getEmploys().clear();
			}
			if(dept.getEmps()!=null && dept.getEmps().size()>0) {
				List<Emp> emps = dept.getEmps();
				for (Emp emp : emps) {
					emp.setDept(null);
				}
				empDAO.save(emps);
				dept.getEmps().clear();
			}
			if(dept.getLeaves()!=null) {
				/*List<Leave> leaves = dept.getLeaves();
				for (Leave leave : leaves) {
					leave.setDept(null);
				}
				leaveDAO.save(leaves);*/
				dept.getLeaves().clear();
			}
			if(dept.getLoans()!=null && dept.getLoans().size()>0) {
				List<Loan> loans = dept.getLoans();
				for (Loan loan : loans) {
					loan.setDept(null);
				}
				loanDAO.save(loans);
				dept.getLoans().clear();
			}
			if(dept.getOverworks()!=null && dept.getOverworks().size()>0) {
				List<Overwork> overworks = dept.getOverworks();
				for (Overwork overwork : overworks) {
					overwork.setDept(null);
				}
				overworkDAO.save(overworks);
				dept.getOverworks().clear();
			}
			if(dept.getPositions()!=null && dept.getPositions().size()>0) {
				List<Position> positions = dept.getPositions();
				for (Position position : positions) {
					position.setDept(null);
				}
				positionDAO.save(positions);
				dept.getPositions().clear();
			}
			if(dept.getQuits()!=null && dept.getQuits().size()>0) {
				List<Quit> quits = dept.getQuits();
				for (Quit quit : quits) {
					quit.setDept(null);
				}
				quitDAO.save(quits);
				dept.getQuits().clear();
			}
			if(dept.getReloans()!=null && dept.getReloans().size()>0) {
				List<Reloan> reloans = dept.getReloans();
				for (Reloan reloan : reloans) {
					reloan.setDept(null);
				}
				reloanDAO.save(reloans);
				dept.getReloans().clear();
			}
			if(dept.getStandards()!=null && dept.getStandards().size()>0) {
				List<Standard> standards = dept.getStandards();
				for (Standard standard : standards) {
					standard.setDept(null);
				}
				standardDAO.save(standards);
				dept.getStandards().clear();
			}
			if(dept.getTransfers1()!=null && dept.getTransfers1().size()>0) {
				List<Transfer> transfers1 = dept.getTransfers1();
				for (Transfer transfer : transfers1) {
					transfer.setDept1(null);
				}
				transferDAO.save(transfers1);
				dept.getTransfers1().clear();
			}
			if(dept.getTransfers2()!=null && dept.getTransfers2().size()>0) {
				List<Transfer> transfers2 = dept.getTransfers2();
				for (Transfer transfer : transfers2) {
					transfer.setDept2(null);
				}
				transferDAO.save(transfers2);
				dept.getTransfers2().clear();
			}
			Dept save = deptDAO.save(dept);
			System.err.println(save.getPositions().size()+"---");
			deptDAO.delete(dept);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}
	
	
	
	/**
	 * 查询所有部门以及部门下面的职位
	 * --------------------
	 */
	public Object queryDeptAndPosition() {
		List<Dept> depts = deptDAO.findAll();
		List<PositionDeptVo> PositionDeptVos = new ArrayList<>();
		for (Dept dept : depts) {
			PositionDeptVo positionDeptVo = new PositionDeptVo();
			positionDeptVo.setDeptId(dept.getDeptId());
			positionDeptVo.setDeptName(dept.getDeptName());
			List<PositionInfoVo> PositionInfoVos = new ArrayList<>();
			List<Position> positions = dept.getPositions();
			for (Position position : positions) {
				PositionInfoVo positionInfoVo = new PositionInfoVo();
				positionInfoVo.setPositionId(position.getPositionId());
				positionInfoVo.setPositionName(position.getPositionName());
				PositionInfoVos.add(positionInfoVo);
			}
			positionDeptVo.setPositions(PositionInfoVos);
			PositionDeptVos.add(positionDeptVo);
		}
		return JSON.toJSON(PositionDeptVos);
	}
	/**
	 * 根据部门id查询该部门下的职位
	 * @return 
	 */
	public List<PositionInfoVo> queryPositionByDeptId(Integer deptid) {
		Dept dept = deptDAO.findOne(deptid);
		List<Position> positions = dept.getPositions();
		List<PositionInfoVo> positionInfoVos = new ArrayList<>();
		for (Position position : positions) {
			PositionInfoVo positionInfoVo = new PositionInfoVo();
			positionInfoVo.setPositionId(position.getPositionId());
			positionInfoVo.setPositionDesc(position.getPositionDesc());
			positionInfoVo.setPositionLevel(position.getPositionLevel());
			positionInfoVo.setPositionName(position.getPositionName());
			positionInfoVo.setPositionNumber(position.getPositionNumber());
			positionInfoVo.setPositionOrgan(position.getPositionOrgan());
			positionInfoVo.setSuperPosition(position.getPosition()==null?"":position.getPosition().getPositionName());
			positionInfoVo.setSuperPositionId(position.getPosition()==null?0:position.getPosition().getPositionId());
			positionInfoVos.add(positionInfoVo);
		}
		return positionInfoVos;
	}
	/**
	 * 新增职位
	 * @return 
	 */
	public boolean addNewPosition(Integer positionId, String positionDesc, Integer positionLevel, String positionName,
			Integer positionOrgan, Integer superPosition, Integer deptid) {
		try {
			Dept dept = deptDAO.findOne(deptid);
			Position suPosition = positionDAO.findOne(superPosition);
			Position position = null;
			if(positionId>0) {
				position = positionDAO.findOne(positionId);
			}else {
				position = new Position();
			}
			
			position.setDept(dept);
			position.setPositionDesc(positionDesc);
			position.setPositionLevel(positionLevel);
			position.setPositionName(positionName);
			position.setPositionOrgan(positionOrgan);
			position.setPosition(suPosition);
			positionDAO.save(position);
			return true;
		} catch (Exception e) {
			e.getLocalizedMessage();
			return false;
		}
	}
	/**
	 * 查询比当前等级高的职位--用于编辑职位的时候下拉框选择上级职位
	 */
	public List<CreatePositionVo> queryLevelMaxPosition(Integer level) {
		List<Position> positions = positionDAO.findAll();
		List<CreatePositionVo> createPositionVos = new ArrayList<>();
		createPositionVos.add(new CreatePositionVo(0,"--无--"));
		for (Position position : positions) {
			if(position.getPositionLevel()<level) {
			CreatePositionVo createPositionVo = new CreatePositionVo();
			createPositionVo.setPositionId(position.getPositionId());
			createPositionVo.setPositionName(position.getPositionName());
			createPositionVos.add(createPositionVo);
			}
		}
		return createPositionVos;
	}
	/**
	 * 根据部门id查询该部门下的所有员工
	 */
	public List<EmpRoleVo> queryDeptAllEmpInfo(Integer deptid) {
		Dept dept = deptDAO.findOne(deptid);
		List<Emp> emps = dept.getEmps();
		List<EmpRoleVo> empRoleVos = new ArrayList<>();
		for (Emp emp : emps) {
			EmpRoleVo empRoleVo = new EmpRoleVo();
			empRoleVo.setDeptName(emp.getDept()==null?null:emp.getDept().getDeptName());
			empRoleVo.setEmpId(emp.getEmpId());
			empRoleVo.setEmpName(emp.getEmpName());
			empRoleVo.setEmpSex(emp.getEmpSex());
			List<String> rolenames = new ArrayList<String>();
			if(emp.getMenuroles()!=null) {
				for (int i = 0; i < emp.getMenuroles().size(); i++) {
					rolenames.add(emp.getMenuroles().get(i).getRoleName());
				}
			}
			empRoleVo.setMenuroles(rolenames);
			empRoleVo.setPositionName(emp.getPosition()==null?null:emp.getPosition().getPositionName());
			empRoleVos.add(empRoleVo);
		}
		return empRoleVos;
	}
	/**
	 * 删除职位
	 * @return 
	 */
	public boolean removeDeptPosition(Integer positionid) {
		try {
		Position position = positionDAO.findOne(positionid);
		if(position.getEmploys()!=null) {
			List<Employ> employs = position.getEmploys();
			for (Employ employ : employs) {
				employ.setPosition(position);
			}
			position.getEmploys().clear();
		}
		if(position.getEmps()!=null) {
			List<Emp> emps = position.getEmps();
			for (Emp emp : emps) {
				emp.setPosition(null);
			}
			position.getEmps().clear();
		}
		if(position.getLeaves()!=null) {
			
			position.getLeaves().clear();
		}
		if(position.getOverworks()!=null) {
			List<Overwork> overworks = position.getOverworks();
			for (Overwork overwork : overworks) {
				overwork.setPosition(null);
			}
			position.getOverworks().clear();
		}
		if(position.getPositions()!=null) {
			List<Position> positions = position.getPositions();
			for (Position position2 : positions) {
				position2.setPosition(null);
			}
			position.getPositions().clear();
		}
		if(position.getTransfers()!=null) {
			List<Transfer> transfers = position.getTransfers();
			for (Transfer transfer : transfers) {
				transfer.setPosition(null);
			}
			position.getTransfers().clear();
		}
		if(position.getQuits()!=null) {
			List<Quit> quits = position.getQuits();
			for (Quit quit : quits) {
				quit.setPosition(null);
			}
			position.getQuits().clear();
		}
		positionDAO.delete(positionid);
			return true;
		}catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}
	/**
	 * 查询所有部门--用于职位管理的部门树
	 */
	public List<DeptVo> queryAllDept() {
		List<Dept> depts = deptDAO.findAll();
		List<DeptVo> deptvos = new ArrayList<>();
		for (Dept dept : depts) {
			DeptVo deptVo = new DeptVo();
			deptVo.setDeptId(dept.getDeptId());
			deptVo.setDeptname(dept.getDeptName());
			deptvos.add(deptVo);
		}
		return deptvos;
	}
	/**
	 * 查询部门下面没有职位的员工       
	 */
	public List<EmpVo> queryDeptNotPositionEmp(Integer deptid) {
		Dept dept = deptDAO.findOne(deptid);
		List<Emp> emps = dept.getEmps();
		List<EmpVo> empvos = new ArrayList<>();
		for (Emp emp : emps) {
			if(emp.getPosition()==null) {
				EmpVo empVo = new EmpVo();
				empVo.setEmpid(emp.getEmpId());
				empVo.setEmpname(emp.getEmpName());
				empvos.add(empVo);
			}
		}
		return empvos;
	}
	/**
	 * 给职位增加员工
	 * @return 
	 */
	public boolean giveEmpToPosition(Integer psoid, String empids) {
		try {
			//截取empids得到empids数组
			String[] arrempids = empids.split(",");
			Position position = positionDAO.findOne(psoid);
			/*if(position.getEmps()==null) {
				position.setEmps(new ArrayList<>());
			}*/
			for (int i = 0; i < arrempids.length; i++) {
				Emp emp = empDAO.findOne(Integer.parseInt(arrempids[i]));
				emp.setPosition(position);
				position.setPositionNumber(position.getPositionNumber()+1);
				empDAO.save(emp);
			}
			positionDAO.save(position);
			return true;
		}catch(Exception e) {
			e.printStackTrace();
			return false;
		}
	}
	/**
	 * 根据职位id查询拥有该职位的员工
	 */
	public List<EmpVo> queryEmpByPositionId(Integer posid) {
		//根据职位id查询职位
		Position position = positionDAO.findOne(posid);
		//找到拥有该职位的员工
		List<Emp> emps = position.getEmps();
		List<EmpVo> empVos = new ArrayList<>();
		for (Emp emp : emps) {
			EmpVo empVo = new EmpVo();
			empVo.setEmpid(emp.getEmpId());
			empVo.setEmpname(emp.getEmpName());
			empVos.add(empVo);
		}
		return empVos;
	}
}
